import 'dart:io';

import 'package:path/path.dart';

class Utils {
  static final Utils _instance = Utils._internal();
  Utils._internal();

  static Utils getInstance() => _instance;

  late final String execDir;
  final List<Function> shutdown = List.empty(growable: true);

  void init() {
    execDir = dirname(Platform.resolvedExecutable);
    print(execDir);
  }

  void addShutdownHook(Function function) => shutdown.add(function);

  void exitHook() {
    for (var element in shutdown.reversed) {
      element.call();
    }
  }
}
